package com.micro.train.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 火车座位实体类（简化版，只存储基础属性）
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("列车座位")
public class TrainSeat {
    
    @TableId(value = "座位ID", type = IdType.AUTO)
    private Long seatId;
    
    @TableField("列车ID")
    private Long trainId;
    
    @TableField("车厢ID")
    private Long carriageId;
    
    @TableField("座位号")
    private String seatNumber;
    
    @TableField("座位类型")
    private Integer seatType;
    
    @TableField("价格")
    private BigDecimal price;
    
    @TableField(value = "创建时间", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    @TableField(value = "更新时间", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
    
    /**
     * 座位类型枚举
     */
    public enum SeatType {
        FIRST_CLASS(1, "一等座"),
        SECOND_CLASS(2, "二等座"),
        BUSINESS(3, "商务座"),
        SOFT_SLEEPER(4, "软卧"),
        HARD_SLEEPER(5, "硬卧"),
        HARD_SEAT(6, "硬座");
        
        private final Integer code;
        private final String description;
        
        SeatType(Integer code, String description) {
            this.code = code;
            this.description = description;
        }
        
        public Integer getCode() {
            return code;
        }
        
        public String getDescription() {
            return description;
        }
        
        public static SeatType fromCode(Integer code) {
            for (SeatType type : values()) {
                if (type.code.equals(code)) {
                    return type;
                }
            }
            return SECOND_CLASS;
        }
    }
    
    /**
     * 获取座位类型描述
     */
    public String getSeatTypeDescription() {
        return SeatType.fromCode(seatType).getDescription();
    }
}
